<?php

namespace HelloAdmin\Controller;

class NodeController extends CommonController {

    private $Node;

    public function __construct() {
        parent::__construct();
        $this->Node = D('Node');
    }

    public function index() {
        $post = $this->GetParam('name,pid');

        if($post['pid'] > 0){
            $where = ' AND `pid` = '.$post['pid'];
        }else{
            $where = ' AND `pid` = 0';
        }
        if(!empty($post['name'])){
             $where .= ' AND `name` like "'.$post['name'].'%"';
        }
        

        $count = $this->Node->GetCount($where);
        parent::backPage($count);
        $data = $this->Node->GetDataByWhere($where, 'node_id DESC', $this->offset, $this->numPerPage, $fields = '');
        $this->assign('Count', $count);

        $this->assign('data', $data[0]);
        $this->display();
    }




    public function add() {
        parent::add();
        if($_GET['node_id'] > 0){
            $name = $this->Node->GetDataById($_GET['node_id'],'name');
            $this->assign('f_name',$name['name']);
        }
        
    }

}
